package com.lovi.generics;

import java.util.ArrayList;

public class Test01 {
    public static void main(String[] args) {
        ArrayList<Animal> animals = new ArrayList<>();
        animals.add(new Dog("a", 1));
        animals.add(new Dog("b", 2));
        animals.add(new Cat("a", 2));
        animals.add(new Cat("b", 3));

        for (Animal animal : animals) {
            System.out.println(animal.name + "-" + animal.age);
        }


    }
}
class Animal{
    String name;
    int age;

    public Animal(String name, int age) {
        this.name = name;
        this.age = age;
    }
}
class Dog extends Animal{

    public Dog(String name, int age) {
        super(name, age);
    }
}
class Cat extends Animal{

    public Cat(String name, int age) {
        super(name, age);
    }
}
